package demo1;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class InsertStudent {

    public static void insert(Connection connection , Student student) throws SQLException {
         String sql = "insert into student values(?,?)";
         int id = student.getId();
         String name = student.getName();
        PreparedStatement statement = connection.prepareStatement(sql);
        statement.setInt(1,id);
        statement.setString(2,name);
         if(statement.executeUpdate()>=1){
             System.out.println("插入成功");
         }else {
             System.out.println("插入失败");
         }

    }
}
